
import bpy
import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类

import engine.initLIB.load_dll as engineLib
import ctypes




class C_Node_场景帧(基类.C_Node_基类):
	bl_dname = 'bl_node_场景帧'
	bl_label = '帧时间'
	
	#m_Value = bpy.props.StringProperty()
	def init(self, context):
		super(C_Node_场景帧, self).f_init(context)
		self.outputs.new('C_Socket_F32', name='当前帧')
		self.outputs.new('C_Socket_I32', name='开始帧')
		self.outputs.new('C_Socket_I32', name='结束帧')
		self.f_toCPP(self.id_data)
		
	def f_toCPP(self, tree):
		engineLib.flexCAPI.f_创建场景帧节点(ctypes.c_wchar_p(tree.name), ctypes.c_wchar_p(self.name), self.f_getPyObject(tree));
	
	def f_update(self):
		data = ( float(bpy.context.scene.frame_current), int(bpy.context.scene.frame_start), int(bpy.context.scene.frame_end) )
		#print("场景更新 = ", data)
		engineLib.flexCAPI.f_node_传入BL数据(ctypes.c_wchar_p(self.id_data.name), ctypes.c_wchar_p(self.name), ctypes.py_object(data));
		#self.outputs['当前帧'].f_setData(bpy.context.scene.frame_current)
		#self.outputs['开始帧'].f_setData(bpy.context.scene.frame_start)
		#self.outputs['结束帧'].f_setData(bpy.context.scene.frame_end)
		
	
		

class C_NODE_MENU_帧时间(bpy.types.Operator):
	bl_idname = 'node.global_node_scene_frame_time'
	bl_label = '帧时间'
	bl_options = {'REGISTER', 'UNDO'}
	
	def execute(operator, context):
		bpy.ops.node.add_node(type='C_Node_场景帧', use_transform=True)
		return {'FINISHED'}






classes = (
	C_Node_场景帧,
	C_NODE_MENU_帧时间,

)

def register():
	for c in classes:
		bpy.utils.register_class(c)
		

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)



